package com.isoftstone.tpl.action;

import java.util.Locale;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.SessionAttributes;

import com.isoftstone.tpl.BaseAction;

/**
 * Handles requests for the application home page.
 */
@Controller
@SessionAttributes
@RequestMapping("")
public class HomeController extends BaseAction {
//	@Resource
//	private UserService userService;
	
	private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
	
	/**
	 * Simply selects the home view to render by returning its name.
	 */
	@RequestMapping(value = "/", method = RequestMethod.GET)
	public String home(Locale locale, Model model) {
		setPageTitle(model, getI18NMessage("pageTitle", locale));
		
		logger.info("Welcome home! The client locale is {}.", locale);
		
		//User user = userService.findById("getUserById", 1);
		//model.addAttribute("serverTime", "user name: " + user.getName());
		
		model.addAttribute("serverTime", "user name: 张三");
		
		return setTilesView("home");
	}
	
	@RequestMapping(value = "test", method = RequestMethod.GET)
	public String my(Locale locale, Model model) {
		return setTilesView("dir/test");
	}
}
